package towa.com.remoteWMP;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class HostArrayAdapter extends ArrayAdapter<Host>{
	private Context context;
	private List<Host> hosts;
	
	public HostArrayAdapter(Context context, List<Host> hosts){
		super(context, R.layout.hostadapterlayout, hosts);
		this.context = context;
		this.hosts = hosts;
	}
		
	@Override
	public View getView(int position, View convertView, ViewGroup parent){
		LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View rowView = inflater.inflate(R.layout.hostadapterlayout, parent, false);
		TextView name = (TextView) rowView.findViewById(R.id.name);
		TextView ipPort = (TextView) rowView.findViewById(R.id.ipPort);
		Host h = hosts.get(position);
		name.setText(h.getName());
		ipPort.setText(h.getIp() + ":" + h.getPort());
		return rowView;
	}

}
